<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<base href="<%=basePath%>">

		<title>广东科学技术职业学院考生报到系统>>>>招就处</title>

		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<link href="css/newindex.css" rel="stylesheet" type="text/css" />
		
		<link rel="stylesheet" href="css/jquery-ui-1.8.5.custom.css"
			type="text/css" />
		<script src="js/jquery-1.5.js" language="javascript">
</script>
<script src="js/newpublic.js" language="javascript">
</script>
		<script src="js/table.js" language="javascript">
</script>
		<script src="js/pageInfo.js" type="text/javascript">
</script>
		<script src="js/jquery-ui-1.8.5.custom.min.js" language="javascript">
</script>
		<script type="text/javascript">
		$(function(){
		
			var isSpecialUser=${sessionScope.isSpecialUser}?true:false ;//特殊帐号，屏蔽增删改的功能
			
			//$("a[id^='changeState'],a[id^='deleteDorm']").attr("href",'javascript:alert("jj")');
			//alert(isSpecialUser)
			if(isSpecialUser){
				window.changeProf=function(){
					alert("Sorry!!该帐号权限不够，不能进行此操作")
				}
			}
		})
var college_name, pro_name, class_index, pageIndex, index_now, size_now;
$(function() {

	$('#colleges').get(0).selectedIndex = 0;
	$('#professions').get(0).selectedIndex = 0;
	$('#clazz').get(0).selectedIndex = 0;
	var collegesList = '<s:property value="collegesJson" escape="false"/>';
	collegesList = eval('(' + collegesList + ')');

	for ( var i = 0; i < collegesList.length; i++) {
		$("#colleges").append(
				"<option value='" + collegesList[i].collegeId + "'>"
						+ collegesList[i].collegesName + "</option>");
	}
	$("#colleges").change(function() {
		if ($(this).val() == '') {//选择了全部学院
				$("#professions").empty();
				$('#clazz').empty();
				$("#professions").append("<option value=''>全部专业</option>");
				$("#clazz").append("<option value=''>全部班级</option>");
				return;
			}
			$.post("json/studentManageAction!showPros", {
				'collegeId' : $(this).val(),
				'data' : new Date()
			}, function(data) {
				list = eval("(" + data.proJson + ")");
				$("#professions").empty();
				$("#professions").append("<option value=''>全部专业</option>");
				for ( var a in list) {
					$("#professions").append(
							"<option value=" + a + ">" + list[a].professionName
									+ "</option>");
				}
				$('#professions').change(function() {
					$('#clazz').empty();
					show($(this.options[this.options.selectedIndex]).val());
				})
				$('#professions').trigger("change")
			})
		});

	$("#query").unbind("click").click(function() {
		var index = 1;
		var size = '<s:property value="pageInfo.pageSize"/>';
		var temp1 = $('#colleges').val();
		var temp2 = $('#professions').val();
		if (temp1 == '' || temp1 == null) {
			college_name = '';
		} else {
			college_name = $('#colleges option:selected').text();
		}
		if (temp2 == '' || temp2 == null) {
			pro_name = '';
		} else {
			pro_name = $('#professions option:selected').text();
		}
		class_index = $('#clazz').val();
		ajaxSubmit(index, size);
	});
})
function show(obj) {
	$('#clazz').empty();
	$("#clazz").append("<option value=''>全部班级</option>");
	if (list[obj]) {

		for ( var i = 1; i <= list[obj].classes; i++) {
			$("#clazz").append("<option>" + i + "</option>");
		}
	}

}

function ajaxSubmit(index, size) {
	index_now = index;
	size_now = size;
	var dormNumber = $('#dormNum').val();
	if (dormNumber != '') {
		var p = /^.+#\d*$/;//考虑到老师公寓宿舍号有字母和广州学院宿舍位置有中文的情况
		if (!p.test(dormNumber)) {
			alert("宿舍格式不正确，正确格式为：栋数#宿舍号 (广州校区为：位置#宿舍号) ")
			return;
		}
	}
	$.post("json/studentManageAction!showData", {
		"pageInfo.pageIndex" : index,
		"pageInfo.pageSize" : size,
		"stuName" : $('#stuName').val(),
		"stuExamCode" : $('#stuExamCode').val(),
		"stuIdCode" : $('#stuIdCode').val(),
		"collegesName" : college_name,
		"proName" : pro_name,
		"classIndex" : class_index,
		"dormNum" : dormNumber,
		"data" : new Date()
	}, function(data) {
		var page = eval('(' + data.pageJson + ')');
		initPage(page.totalPage, page.pageIndex, page.pageSize, page.totalRec);
		showResult(data);
	});
}

//显示查询结果
function showResult(data) {
	result = eval("(" + data.showJson + ")");

	if (result.length <= 0) {
		$("#noResult").html("没有查到符合条件的同学!")
		$("#showResult").hide();
		return;
	} else {
		$("#noResult").html("")
	}
	clearMessage();

	for ( var i = 0; i < result.length; i++) {

		$("#showResult").show();
		var name = result[i].studentName;
		var examcode = result[i].examCode;
		var idcode = result[i].idCode;
		var prof = result[i].profession;
		var college = result[i].college;
		var stuId = result[i].studentId;
		var clazz = result[i].clazz;
		var dormNumber = result[i].dormNumber
		var sex = result[i].sex ? "男" : "女"
		var register = result[i].isRegister == true ? result[i].registerTime
				: "<font color='red'>未注册</font>";
		var tr;
		if (i % 2 != 0) {
			tr = '<tr style="background-color:#deefff" name="showStudentMessage" height="30">';
		} else {
			tr = '<tr style="background-color:#ffffff" name="showStudentMessage" height="30">';
		}
		tr += '<td id="num" align="center">'
				+ (i + 1)
				+ '</td><td id="stuName" align="center">'
				+ name
				+ '</td><td align="center">'
				+ sex
				+ '</td><td id="stuExamCode" height="20" align="center">'
				+ examcode
				+ '</td><td id="stuIdCode" align="center">'
				+ idcode
				+ '</td><td id="stuProf" align="center">'
				+ college
				+ '</td><td id="stuProf" align="left">'
				+ prof
				+ clazz
				+ "班"
				+ '</td><td id="studorm" align="left">'
				+ dormNumber
				+ '</td><td  align="center">'
				+ register
				+ '</td><td id="stuProf" align="center">&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:checkStu('
				+ stuId
				+ ')">查看</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:changeProf('
				+ stuId
				+ ')">转专业&nbsp;<font color=red>(慎重)</font> </a></td></tr>';
		$("#searchResult").append($(tr));
	}

}

//清除数据
function clearMessage() {
	$("tr[name='showStudentMessage']").remove();
}

//删除学生
function delStu(i) {
	var studentId = i;
	if (confirm("确定删除?")) {
		$.post("json/studentManageAction!delStu", {
			"stuId" : studentId,
			"data" : new Date()
		}, function(data) {
			alert("删除成功!");
			ajaxSubmit(index_now, size_now);
		})
	}
}
//查看学生信息
function checkStu(i) {
	$.post("json/studentManageAction!showStu", {
		"stuId" : i,
		"data" : new Date()
	}, function(data) {
		var student = eval("(" + data.stuInfoJson + ")");
		var sex = student.sex == true ? "男" : "女";
		$("#check_studentName").html(student.studentName);
		$("#check_sex").html(sex);
		$("#check_examCode").html(student.studentNumber);
		$("#check_collegeName").html(student.college);
		$("#check_professionName").html(student.profession);

		$("#check_class").html(student.clazz + "&nbsp;班");
		$("#check_politicsStatus").html(student.politicsStatus);
		$("#check_score").html(student.score + "分");
		var dormNumber, registerTime;
		$("#check_unpayment").html(student.unpaidFees);
		$("#check_fee").html(student.feePayable);
		if (student.registerTime) {
			registerTime = student.registerTime
		} else {
			registerTime = "<font color='red'>未注册</red>"
		}
		$("#check_unpayment").html(student.unpaidFees)
		$("#check_registerTime").html(registerTime);
		if (student.dormNumber) {
			$("#check_dormNumber").html(student.dormNumber);
		} else {
			$("#check_dormNumber").html("<font color='red'>未分配</red>");
		}
		$("#studentInfoDialog").show()
		//显示 div
			$("#studentInfoDialog").dialog( {
				modal : true,
				width : 700,
				buttons : {
					"确定" : function() {
						$("#studentInfoDialog").hide()
						$(this).dialog("close");
					}
				}
			})
		})
}
//清空注册信息
function clearRegisterInfo(i) {
	var studentId = i;
	if (confirm("确定清除譔学生的注册信息？?")) {
		$.post("json/studentManageAction!clearRegisterInfo", {
			"studentId" : studentId
		}, function(data) {
			if (eval(data.result)) {
				alert("清除成功!");
				ajaxSubmit(index_now, size_now);
			} else {
				alert("清除失败!");
			}
		})
	}
}
function changeProf(i) {

	$('#toCollegeName').empty();
	$('#professionName').empty();
	$('#toClassName').empty();

	var studentId = i;
	$.post(
					"json/studentManageAction!showStu",
					{
						"stuId" : studentId,
						"data" : new Date()
					},
					function(data) {
						var student = eval("(" + data.stuInfoJson + ")");

						var register = student.isRegister == true ? student.registerTime
								: "未注册";
						$("#name").html(student.studentName);
						$("#isRegister").html(register);
						$("#code").html(student.examCode);
						$("#currentCollegeName").html(student.college);
						$("#currentProfessionName").html(student.profession);
						$("#currentClass").html(student.clazz);
						var toCollegesList = '<s:property value="collegesJson" escape="false"/>';
						toCollegesList = eval('(' + toCollegesList + ')');
						for ( var i = 0; i < toCollegesList.length; i++) {
							$("#toCollegeName").append(
									"<option value='"
											+ toCollegesList[i].collegeId
											+ "'>"
											+ toCollegesList[i].collegesName
											+ "</option>");
						}
						$("#toCollegeName").unbind("change")
						$("#toCollegeName")
								.change(
										function() {

											$
													.post(
															"json/studentManageAction!showPros",
															{
																'collegeId' : $(
																		this)
																		.val(),
																'data' : new Date()
															},
															function(data) {
																list = eval("("
																		+ data.proJson
																		+ ")");
																$(
																		"#toProfessionName")
																		.empty();
																for ( var a in list) {
																	$(
																			"#toProfessionName")
																			.append(
																					"<option value="
																							+ a
																							+ ">"
																							+ list[a].professionName
																							+ "</option>");
																}
																$(
																		'#toProfessionName')
																		.change(
																				function() {
																					toShow($(
																							'#toProfessionName')
																							.val());

																				})
																$(
																		"#toProfessionName")
																		.trigger(
																				"change")
															})

										});

						$("#toCollegeName").trigger("change")

						$("#changeStuProDialog").show();
						//显示 div
						$("#changeStuProDialog")
								.dialog(
										{
											modal : true,
											width : 700,
											buttons : {
												"确定" : function() {
													$
															.post(
																	"json/studentManageAction!changePro",
																	{
																		"studentId" : studentId,
																		"collegeId" : $(
																				"#toCollegeName")
																				.val(),
																		"professionId" : $(
																				"#toProfessionName")
																				.val(),
																		"classIndex" : $(
																				'#toClassName')
																				.val(),
																		"date" : new Date()
																	},
																	function(
																			data) {
																		alert("已经成功为该同学转了专业！\n请注意!请让该学生到新学院重新注册！");
																		$(
																				"#changeStuProDialog")
																				.hide();
																		$(
																				"#changeStuProDialog")
																				.dialog(
																						"close");
																		ajaxSubmit(
																				index_now,
																				size_now);
																	});
												},
												"取消" : function() {
													$("#changeStuProDialog")
															.hide();
													$(this).dialog("close");
												}
											}
										})
					})
}

function toShow(obj) {
	$('#toClassName').empty();
	for ( var i = 1; i <= list[obj].classes; i++) {
		$("#toClassName")
				.append("<option value='" + i + "'>" + i + "</option>");
	}
}
</script>
	</head>

	<body onload="fixPNGAll()">
		<div id="bg">
			<div id="bodydiv">
				<div id="bodytitle"> 
					招就处 
					<div>
						<a href="logoutAction" style="color: #F00;">退出</a>
					</div>
				</div>

				<div id="menudiv">

					<jsp:include page="entrance_header.jsp" />

				</div>
				
				
				<div id="content">
					<!--当前位置CSS-->
					<div class="top">
						<div class="topleft">
							<div class="dan">
								<div>
									当前位置>招就处>各学院概况
								</div>
							</div>
							<div class="F5">
								<img src="newimages/F5.png" />
							</div>
						</div>
						<div class="topright">
							<div class="toprightmin"></div>
							<div class="toprightmax"></div>
							<div class="toprightclose"
								onclick="if(confirm('是否确定退出！')){location.replace('loginoutAction')}"
								title="点击退出"></div>
						</div>
					</div>
					<!---->
					<!--内容-->
					<div class="condiv">
						<div class="submenu">

						</div>
						<div class="contable">
							<!--******************************-->
							<div id="t1" style="display: block;">
								<div class="title">
									学生管理
								</div>
								<div id="man_zone">
									<!--************************************************************-->
									<table width="700" border="0" align="center" cellpadding="0"
										cellspacing="5" style="margin-top: 20px;">
										<tr>
											<td>
												姓名：
											</td>
											<td>
												<input name="stuName" type="text" id="stuName" />
											</td>
											<td>
												准考证：
											</td>
											<td>
												<input name="stuExamCode" type="text" id="stuExamCode" />
											</td>
											<td>
												身份证：
											</td>
											<td>
												<input name="stuIdCode" type="text" id="stuIdCode" />
											</td>
										</tr>
										<tr>
											<td>
												学院选择：
											</td>
											<td>
												<select id="colleges" name="collegesName">
													<option value="">
														全部
													</option>
												</select>
											</td>
											<td>
												专业：
											</td>
											<td>
												<select id="professions" name="proName">
													<option value="">
														全部专业
													</option>

												</select>
											</td>
											<td>
												班级：
											</td>
											<td>
												<select id="clazz" name="classIndex">
													<option value="">
														全部
													</option>
												</select>
											</td>
										</tr>
										<tr>
											<td>
												宿舍号：
											</td>
											<td>
												<input id="dormNum" name="dormNum" type="text" size="13" />

											</td>
											<td>
												&nbsp;
											</td>
											<td>
												&nbsp;
											</td>
											<td>
												&nbsp;
											</td>
											<td>
												<input id="query" type="button"
													value="&nbsp;&nbsp;查&nbsp;询&nbsp;&nbsp;" />
											</td>
										</tr>
									</table>
									<!--************************************************************-->
									<span id="noResult" style="color: red; font-size: 20px"></span>
									<div id="showResult" style="display: none;overflow:auto;_overflow-y:visible;_width:947px;">
										<table id="searchResult" width="900" border="0" align="center"
											cellpadding="0" cellspacing="1" class="t1"
											style="border: 1px solid #5cb0ff; margin-top: 20px;">
											<tr style="color: #000;">
												<th align="center">
													序号
												</th>
												<th align="center">
													姓名
												</th>
												<th align="center">
													性别
												</th>
												<th align="center">
													准考证
												</th>
												<th align="center">
													身份证
												</th>
												<th align="center" width="10%">
													学院
												</th>
												<th align="center">
													班级
												</th>
												<th align="center">
													宿舍
												</th>
												<th align="center">
													注册时间
												</th>
												<th align="center">
													操作
												</th>
											</tr>
										</table>
										<!--上一页，下一页 开始-->
										<table width="900" border=0 class="pagecss" align="center">
											<tr>
												<td align="left">
													<span id="AllPage">共几页/几条</span>
													<span id="setupNum">显示每页记录条数</span>
													<select id="setSize"
														onchange="ajaxChangeCount(this.options[this.options.selectedIndex].value)">
													</select>
												</td>
												<td align="right">
													<span id="Flexigrid_Bar"><a href="">上5页</a>&nbsp;<span
														class="dan">1</span>&nbsp;<a href="">2</a>&nbsp;<a href="">3</a>&nbsp;<a
														href="">下5页</a>&nbsp; </span>
													<span id="checkPage"><input type="text"
															style="width: 20px;"> &nbsp;页<a href="">GO</a> </span>
												</td>
											</tr>
										</table>
										<!--上一页，下一页 结束-->
										<!--************************************************************-->
									</div>
									</div>
								</div>
								</div>
								<!--*******//////////////----------------  -->
								<!-- 参看学生信息 -->
								<div id="studentInfoDialog" title="查看学生信息" style="display: none">
									<table border="0" width="515" align="center" cellspacing="10">
										<tr>
											<td width="38" align="right">
												姓名：
											</td>
											<td width="69" align="left" id="check_studentName">
												张三
											</td>
											<td width="44" align="right">
												性别：
											</td>
											<td width="56" align="left" id="check_sex">
												男
											</td>
											<td width="56" align="right">
												班内序号：
											</td>
											<td width="91" align="left" id="check_examCode">
												123456
											</td>
										</tr>
										<tr>
											<td align="right">
												学院：
											</td>
											<td id="check_collegeName">
												计算机学院
											</td>
											<td align="right">
												专业：
											</td>
											<td id="check_professionName">
												软件技术
											</td>
											<td align="right">
												班级：
											</td>
											<td id="check_class">
												2
											</td>
										</tr>
										<tr>
											<td align="right">
												成绩：
											</td>
											<td id="check_score">

											</td>
											<td align="right">
												政治面貌
											</td>
											<td id="check_politicsStatus">
												2
											</td>
											<td align="right">
												注册时间
											</td>
											<td id="check_registerTime">

											</td>
										</tr>
										<tr>
											<td align="right">
												宿舍号
											</td>
											<td id="check_dormNumber">

											</td>
											<td>
												学费：
											</td>
											<td id="check_fee">

											</td>
											<td align="right">
												欠费金额:
											</td>
											<td id="check_unpayment">

											</td>
										</tr>

									</table>
								</div>

								<!-- 修改学生专业     -->
								<div id="changeStuProDialog" title="修改学生专业"
									style="display: none">
									<table border="0" width="670" align="center" cellspacing="10">
										<tr>
											<td width="15%" align="right">
												姓名：
											</td>
											<td id="name" width="15%" align="left">
												张三
											</td>
											<td width="15%" align="right">
												准考证：
											</td>
											<td id="code" width="15%" align="left">
												123456
											</td>
											<td width="20%" align="right">
												注册状态：
											</td>
											<td id="isRegister" width="20%" align="left">
												未注册
											</td>
										</tr>
										<tr>
											<td align="right" align="right">
												当前学院：
											</td>
											<td id="currentCollegeName" align="left">
												计算机学院
											</td>
											<td align="right" align="right">
												当前专业：
											</td>
											<td id="currentProfessionName" align="left">
												软件技术
											</td>
											<div style="display: none">
												<td align="right">
													当前班级：
												</td>
												<td id="currentClass" align="left">
													2
												</td>
											</div>
										</tr>
										<tr>
											<td align="right" align="right">
												转学院：
											</td>
											<td align="left">
												<select id="toCollegeName">
													<option>
														全部
													</option>
												</select>
											</td>
											<td align="right" align="right">
												转专业：
											</td>
											<td align="left">
												<select id="toProfessionName">
													<option>
														全部
													</option>
												</select>
											</td>
											<td align="left">
												<select id="toClassName">
													<option>
														全部
													</option>
												</select>
											</td>
										</tr>
									</table>
								</div>
								
							</div>
						</div>
						<!---->
						<!---->
						<div id="content">
						<div class="condiv"
					style="width: 997px; position: relative; height: 20px; min-height: 20px; text-align: center;">
						<a href="computer/computer.html" target="_blank">计算机学院程序员之家</a>
					</div>
					</div>
						<!---->

						<!--低部-->
						<div id="content">
						<div class="bottom">
							&nbsp;
						</div>
						</div>
						<!---->
					</div>
				</div>
			</div>
	</body>
</html>
